//
//  STMeCell.m
//  CuiBoStore
//
//  Created by 崔博 on 16/11/30.
//  Copyright © 2016年 崔博. All rights reserved.
//

#import "STMeCell.h"

@interface STMeCell ()
@property (nonatomic , strong) UIImageView *iconView;
@property (nonatomic , strong) UILabel *titleLabel;
@property (nonatomic , strong) UIImageView *arrowImageView;
@property (nonatomic , strong) UIView *lineView;
@property (nonatomic , strong) UILabel *leftLabel;
@end

@implementation STMeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addSubviews];
    }
    return  self;
}

// addsubvies
- (void)addSubviews
{
    [self addSubview:self.iconView];
    [self addSubview:self.titleLabel];
    [self addSubview:self.arrowImageView];
    [self addSubview:self.leftLabel];
    [self addSubview:self.lineView];
    
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.left.equalTo(@15);
        make.centerY.equalTo(self);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_iconView.mas_right).offset(15);
        make.centerY.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(140, 15));
    }];
    
    [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(10, 14));
        make.centerY.equalTo(self);
        make.right.equalTo(@(-15));
    }];
    [_leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(@(-15));
    }];
    
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@1);
        make.left.equalTo(_titleLabel.mas_left);
        make.right.equalTo(self);
        make.bottom.equalTo(@(-1));
    }];
}
#pragma mark - set
- (void)setItemModel:(STItemModel *)itemModel
{
    _itemModel = itemModel;
    self.iconView.image = [UIImage imageNamed:itemModel.image];
    self.titleLabel.text = itemModel.title;
    self.leftLabel.text = itemModel.leftTitle;
}

#pragma mark - lazy
- (UIImageView *)iconView
{
    if (!_iconView) {
        _iconView = [[UIImageView alloc] init];
    }
    return _iconView;
}

- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [STUIKitTools lableFont:15 textColor:[UIColor blackColor]];
    }
    return _titleLabel;
}

- (UIImageView *)arrowImageView
{
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] init];
        _arrowImageView.image = [UIImage imageNamed:@"下一步"];
    }
    return _arrowImageView;
}
- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = BACKGROUND_COLOR;
    }
    return _lineView;
}

- (UILabel *)leftLabel
{
    if (!_leftLabel) {
        _leftLabel = [STUIKitTools lableFont:15 textColor:[UIColor lightGrayColor]];
    }
    return _leftLabel;
}
@end
